-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(WIP) Update the parameter type annotations for pyqtSignal.__init__ #107
base: master
Are you sure you want to change the base?
(WIP) Update the parameter type annotations for pyqtSignal.__init__ #107
Conversation
The *types annotation is currently broken. Feedback appreciated
@@ -40,9 +40,22 @@ class pyqtBoundSignal: | |||
@typing.overload | |||
def disconnect(self, slot: typing.Union["PYQT_SLOT", "QMetaObject.Connection"]) -> None: ... | |||
|
|||
|
|||
_SignalTypesT = typing.TypeVar("_SignalTypesT", type, typing.List[type]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_SignalTypesT = typing.TypeVar("_SignalTypesT", type, typing.List[type]) | |
_SignalTypesT = typing.TypeVar("_SignalTypesT", typing.Union[type, typing.List[type]]) |
I can't say I know the reasons for why this works and the separate types don't but... it does. :|
Is there something that makes it wrong despite passing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err, hold that thought... maybe I didn't test properly here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, trying again and hoping to be less silly. As is, there is no relationship being created between multiple hints so this can just be an alias instead, I think?
_SignalTypesT = typing.TypeVar("_SignalTypesT", type, typing.List[type]) | |
_SignalTypesT = typing.Union[type, typing.List[type]] |
(except with a different variable name changed here and at the use sites)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue here is that I need to keep all of the var args of the same type. Using the Union allows for
a = pyqtSignal([int, bool], float)
but this is not allowed by PyQt. You can use only types OR only lists of types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I think my second attempt was less silly... though still not helpful. Humm.
Resolves #105
The *types annotation is currently broken. Feedback appreciated
Minimal reprduction of issue:
https://mypy-play.net/?mypy=latest&python=3.8&gist=57db3e86d7202dc8ebe4f24965409a3f
Edit: Opened an issue on the mypy issue tracker: python/mypy#9569